package com.itheima.mapper;

import cn.hutool.core.date.DateTime;
import com.itheima.domain.EmpQueryParam;
import com.itheima.domain.pojo.Emp;
import com.itheima.domain.pojo.JobOption;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {
//    @Select("select count(*) from emp")
//    Long getTotal();

    //@Select("select e.*,d.name from emp e left join dept d on e.dept_id = d.id order by update_time desc limit #{start},#{pageSize}")
//    @Select("select e.*,d.name from emp e left join dept d on e.dept_id = d.id order by update_time desc limit #{start},#{pageSize}")

    List<Emp> getRows(EmpQueryParam e);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into emp (username,password,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time) values(#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);

    List<Emp> getEmps();

    void deleteByIds(List<Integer> ids);

    Emp getById(Integer id);

    void updateById(Emp emp);
    //员工职位人数统计
    @MapKey("job")
    List<Map<String, Object>> getEmpJobData();
    //员工性别人数统计
    List<Map> getEmpGenderData();


    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp selectByUsernameAndPassword(String username, String password);
}
